﻿using System;
using System.Collections.Generic;
using System.Linq;

class Graph
{
    private int[,] nodes;

    public Graph(int[,] nodes)
    {
        this.nodes = nodes;
    }

    public Stack<int> FindEulerCycle(int startNode)
    {
        int[,] graphCopy = new int[nodes.GetLength(0), nodes.GetLength(1)];
        Array.Copy(nodes, graphCopy, nodes.GetLength(0) * nodes.GetLength(1));

        Stack<int> currentCycle = new Stack<int>();
        Stack<int> eulerCycle = new Stack<int>();
        currentCycle.Push(startNode);

        while (currentCycle.Count > 0)
	    {
	        int currentNode = currentCycle.Peek();
            bool hasChilds = true;
            for (int i = 0; i < graphCopy.GetLength(0); i++)
			{
			    if (graphCopy[currentNode,i] == 1)
	            {
		            graphCopy[currentNode,i] = 0;
                    currentNode = i;
                    
                    break;
	            }
                if (i == graphCopy.GetLength(0) - 1)
                {
                    hasChilds = false;
                }
			}

            if (hasChilds)
            {
                currentCycle.Push(currentNode);
            }
            else
            {
                eulerCycle.Push(currentCycle.Pop());
            }
	    }

        return eulerCycle;
    }

    public bool IsEulerGraph()
    {
        for (int i = 0; i < nodes.GetLength(0); i++)
        {
            int degree = 0;
            for (int j = 0; j < nodes.GetLength(1); j++)
            {
                if (nodes[i,j] == 1)
                {
                    degree++;
                }
                if (nodes[j,i] == 1)
                {
                    degree--;
                }
            }

            if (degree != 0)
            {
                return false;
            }
        }

        return true;
    }
}

class Program
{
    static void Main(string[] args)
    {
        Graph graph = new Graph(ReadGraph());

        if (graph.IsEulerGraph())
        {
            PrintResult(graph.FindEulerCycle(0));
        }
        else
        {
            Console.WriteLine("No");
        }
    }

    static void PrintResult(Stack<int> eulerCycle)
    {
        // Print Euler cycle in format {start node1 node2 ... end}
        while (eulerCycle.Count > 0)
        {
            if (eulerCycle.Count > 1)
            {
                Console.Write("{0} ", eulerCycle.Pop());
            }
            else
            {
                Console.WriteLine(eulerCycle.Pop());
            }
        }
    }

    static int[,] ReadGraph()
    {
        // Read graph as adjacency matrix
        string input = Console.ReadLine();
        int N = int.Parse(input);

        int[,] graph = new int[N, N];
        for (int i = 0; i < N; i++)
        {
            input = Console.ReadLine();
            string[] rowElements = input.Split(", ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
            for (int j = 0; j < N; j++)
            {
                graph[i, j] = int.Parse(rowElements[j]);
            }
        }

        return graph;
    }
}

